package com.srit.recipes.common.response;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONType;

@JSONType(serializeEnumAsJavaBean = true)
public enum Response {
    /*
  成功状态值
  */
    success("successful", new JSONObject(), 200),
    successDate("successful",null,200),
    error("error",new JSONObject(),400),
    errorDate("error",null,400),
    errorDateState("error",null,null),
    tokenException("token异常",null,401),
    tokenInvalid("token失效",null,402);

    private String message;
    private Object data;
    private Integer state;

    Response(String message, Object data, Integer state) {
        this.message = message;
        this.data = data;
        this.state = state;
    }

    public static Response success(Object data){
        successDate.setData(data);
        return successDate;
    }
    public static Response error(Object data){
        errorDate.setData(data);
        return errorDate;
    }
    public static Response error(String data, Integer state){
        errorDateState.setMessage(data);
        errorDateState.setState(state);
        return errorDateState;
    }





    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }
}
